import sys
import os
import os.path
from pathlib import PurePath


def walk_to_file(dir_path, file_name):
    with open(file_name, 'w', encoding='utf-8') as file:
        for root, _, files in os.walk(dir_path):
            for item in files:
                item_path = os.path.join(root,item)
                print('{},{}'.format(item, PurePath(item_path).as_posix()), file=file)


# walk_dir_to_file('D:/temp', 'walk.txt')


if __name__ == '__main__':
    if len(sys.argv) < 3:
        print('缺少参数!')
    else:
        src = sys.argv[1]
        dst = sys.argv[2]
        print('Start...')
        walk_to_file(src, dst)
        print('Done')
